package io高级流or处理流;

import java.awt.event.FocusListener;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class PWDemo2 {
    public static void main(String[] args) throws IOException {
        FileOutputStream fol = new FileOutputStream("./src/io高级流or处理流/jk.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fol,StandardCharsets.UTF_8);
        BufferedWriter bw = new BufferedWriter(osw);
        PrintWriter pw = new PrintWriter(bw,true);

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入文字， 输入exit时退出程序");
        while (true){
            String next = scanner.next();
            if ("exit".equals(next)){
                System.out.println("退出");
                break;
            }
            pw.println(next);

        }
        pw.close();

//        FileOutputStream fol = new FileOutputStream("./src/io高级流or处理流/jk.txt");
//
//        //转换流（高级流，属于字符流） 1.连接字节与字符流，并把字符转成字节  并写出
//        OutputStreamWriter osw = new OutputStreamWriter(fol, StandardCharsets.UTF_8);
//
//        //缓冲流 加速
//        BufferedWriter bw = new BufferedWriter(osw);
//        //
//        PrintWriter pw = new PrintWriter(bw,true);
//        Scanner scanner = new Scanner(System.in);
//        System.out.println("请输入文字，输入exit会退出程序");
//        while (true){
//            String next = scanner.next();
//            if ("exit".equals(next)){
//                System.out.println("退出记事本");
//                break;
//            }
//            pw.println(next);
//        }
//        pw.close();
    }
}
